<template>
  <div class="container">
    <van-nav-bar fixed title="首页" />
    <!-- 轮播图 -->
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in imgURL" :key="item.id">
        <img
          class="banner-img"
          :src="'http://124.223.14.236:8060/' + item.advimgsrc"
          alt=""
        />
      </van-swipe-item>
      <!-- <van-swipe-item>
        <img class="banner-img" src="@/assets/imgs/banner.jpeg" alt="" />
      </van-swipe-item>
      <van-swipe-item>
        <img class="banner-img" src="@/assets/imgs/banner.jpeg" alt="" />
      </van-swipe-item> -->
    </van-swipe>
    <!-- 通知 -->
    <van-notice-bar
      left-icon="volume-o"
      text="在代码阅读过程中人们说脏话的频率是衡量代码质量的唯一标准。"
    />
    <!-- 热门推荐 -->
    <van-cell>
      <h3 slot="title" class="group-title">热门推荐</h3>
    </van-cell>
    <recommend-list v-for="item in hotList" :key="item.id" :item="item" />
    <!-- 最近更新 -->
    <van-cell>
      <h3 slot="title" class="group-title">最近更新</h3>
      <span>24小时： <b>0篇</b></span> /
      <span>1周： <b>0篇</b></span>
    </van-cell>
    <article-list v-for="item in newList" :key="item.id" :item="item" />
  </div>
</template>
<script>
import axios from "axios";
import articleList from "@/components/article-list.vue";
import RecommendList from "../components/recommend-list.vue";
export default {
  components: { articleList, RecommendList },
  data() {
    return {
      hotList: [],
      currentPage:1,
      page: "",
      limit: "",
      newList: [],
      imgURL: [],
    };
  },
  created() {
    this.getIndexList();
    this.getHotList();
    this.getNewList();
  },
  methods: {
    async getIndexList() {
      const { data } = await axios.get(
        "http://124.223.14.236:8060/home/index/index"
      );
      console.log(data);
      // 图片链接
      this.imgURL.push(...data.data.banner);
    },
    async getHotList() {
      let { data } = await axios.get(
        "http://124.223.14.236:8060/home/index/hot"
      );
      console.log(data);
      // 将数据追加到列表中
      this.hotList.push(...data.data.list);
    },
    async getNewList() {
      let { data } = await axios.get(
        "http://124.223.14.236:8060/home/index/new"
      );
      // console.log(data.data.list.data);
      this.newList.push(...data.data.list.data);
    },
  },
};
</script>
<style scoped lang="less">
.banner-img {
  width: 100%;
}
.group-title {
  color: #1989fa;
}
</style>
